package com.nowcoder.community.dao;

import com.nowcoder.community.entity.LoginTicket;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
@Deprecated
public interface LoginTicketMapper {
    /**
     * 新增登入人员
     * @author ProgramCat
     * @param loginTicket 登录信息表
     * @return int
     */
    @Insert({
            "insert into login_ticket(user_id,ticket,status,expired)",
            "values(#{userId},#{ticket},#{status},#{expired})"
    })
    int insertLoginTicket(LoginTicket loginTicket);

    /**
     * 根据ticket查询表
     * @author ProgramCat
     * @param ticket 登录信息表
     * @return LoginTicket
     */
    @Select({
            "select id,user_id,ticket,status,expired ",
            "from login_ticket where ticket=#{ticket}"
    })
    LoginTicket selectByTicket(String ticket);

    /**
     * 更新登录状态
     * @author ProgramCat
     * @param ticket 登录信息表
     * @param status 登录状态（0-有效，1-无效）
     * @return int
     */
    @Update({
            "update login_ticket set status=#{status} where ticket=#{ticket}"
    })
    int updateStatus(String ticket, int status);
}
